clear all

use "study1data.dta"


*post-only 
reg postdv treat PID ideo if design==0

*within-subjects
ttest welfare=poor

*Figure 1
gen est=.
gen se=.
gen x=_n
replace x=. if _n>2

reg postdv treat PID ideo if design==0
est store m1
replace se=_se[treat] in 1
replace est=_b[treat] in 1

ttest welfare=poor
replace se=r(se) in 2
replace est=r(mu_1)-r(mu_2) in 2
gen lo=est-1.96*se
gen hi=est+1.96*se


twoway (scatter est x if x==1, mcol(black)) (scatter est x if x==2, mcol(gray)) ///
	(rspike lo hi x if x==1, lcol(black)) (rspike lo hi x if x==2, lcol(gray) ///
	graphregion(color(white)) legend(off) ylab(.15(.15)-.45, labsize(medsmall)) ///
	yline(0) xlab(1 "Post-only" 2 "Within-subjects", labsize(medsmall)) ///
	xsc(range(0.5 2.5)) xtitle("") subtitle("Study 1: Welfare") ///
	saving(study1.gph, replace) plotregion(margin(zero)) graphregion(margin(1 1 1 1))) 
	
*testing equality of coefficients
keep spend*  pretreated PID ideo predv 
rename spendwelfare1 spendpoor3
rename spendwelfare2 spendpoor4
gen ID=_n

reshape long spendpoor, i(ID) j(var)
recode var 1/2=0 3/4=1, gen(treat)

xtset ID
xtreg spendpoor i.treat##i.pretreated PID ideo, vce(cluster ID) re
